.shinylive-editor {
  --bg-light-shade-color: #f6f6f6;
  --button-gray-color: #999;
  --button-hover-color: #hsl(207, 69%, 25%);
  --border-color: #aaa;
  --pad: 5px;
  display: grid;
  /* By using auto as the height for the first row it will shrink to zero if
  nothing is provided */
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "header"
    "editor";
  position: relative;
}

/* Enforce a max height for the editor-viewer mode unless the user has dragged
the size bigger.  */
.ResizableGrid.editor-viewer.layout-vertical:not(.been-dragged)
  > .shinylive-editor {
  max-height: 800px;
}

.editor-header {
  grid-area: header;
}
.editor-container {
  grid-area: editor;
}

.shinylive-editor > div {
  min-width: 0;
  min-height: 0;
}

.editor-header {
  display: flex;
  padding-top: var(--pad);
  padding-left: var(--pad);
  padding-right: var(--pad);
  justify-content: space-between;
  align-items: flex-end;
  border-bottom: 1px solid var(--border-color);
}

.editor-files > button {
  font-size: 14px;
  font-family: var(--font-face);
  height: 26px;
  background-color: var(--bg-light-shade-color);
  color: #444;
  border: 1px solid #ddd;
  border-top-left-radius: 3px;
  border-top-right-radius: 3px;
  border-bottom: none;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  padding: 0 2px;
}

.editor-files button svg {
  /* When Bootstrap is used, it sets vertical-align:middle for svg, but that
   * messes up alignment of our svg icons. */
  vertical-align: unset;
}

.editor-filename {
  padding: 0 4px;
}

.editor-files > button.selected {
  color: black;
  background-color: var(--colors-bg);
  border-color: var(--border-color);
  position: relative;
  cursor: text;
}

.editor-files > button.selected::after {
  content: "";
  width: 100%;
  height: 4px;
  background-color: var(--colors-bg);
  position: absolute;
  bottom: -3px;
  left: 0;
  border-bottom-color: var(--colors-bg);
}

.editor-files > button.selected > input {
  width: 100%;
  font-size: 14px;
  font-family: var(--font-face);
  height: 26px;
  position: absolute;
  left: 4px;
  bottom: -0.5px;
  outline: none;
  border: none;
  color: var(--colors-blue);
  background-color: transparent;
}

.editor-files > button.selected > input.invalid-filename {
  color: var(--colors-red);
}

.editor-files > button > .editor-closebutton {
  width: 1.2rem;
  display: inline-block;
  color: var(--button-gray-color);
  font-weight: bold;
}

.editor-files > button.selected > .editor-closebutton + input {
  /* If there's a close button, make the input a bit smaller so it doesn't
  overlap the close button. */
  width: calc(100% - 21px);
}

.editor-files > .editor-addtab {
  /* Make the border invisible, but keep the inherited thickness. This is to
  keep things aligned properly. */
  border-color: rgba(0, 0, 0, 0);
  display: inline-block;
  line-height: 1rem;
  margin-left: 0.5rem;
  padding: 0;
}

.editor-files .editor-addbutton,
.editor-files .editor-uploadbutton {
  display: inline-block;
  color: var(--button-gray-color);
  fill: var(--button-gray-color);
  background-color: inherit;
  font-size: 1.2rem;
  font-weight: bold;
  padding: 0 0.3rem;
}

.editor-files .editor-uploadbutton {
  font-size: 0.7rem;
}

.editor-files .editor-closebutton:hover,
.editor-files .editor-addbutton:hover,
.editor-files .editor-uploadbutton:hover {
  color: var(--button-hover-color);
  fill: var(--button-hover-color);
  /* border-radius: 3px; */
  cursor: pointer;
}

.editor-container {
  padding: var(--pad);
  position: relative;
}

.editor-container .cm-editor {
  height: 100%;
}

.editor-container .cm-editor.cm-focused {
  /* Don't show outline on focused editor. (Override CodeMirror default) */
  outline: none;
}

.editor-container .cm-editor .cm-scroller {
  font-family: var(--font-mono-face);
  font-size: var(--font-mono-size);
}

.editor-container .cm-gutters {
  color: #aaa;
  background-color: var(--colors-bg);
  border-right: 1px solid #eee;
  /* border-right: none; */
  padding-right: 4px;
}

.editor-container .cm-activeLineGutter {
  background-color: var(--colors-bg);
}

.editor-container .cm-tooltip {
  font-family: var(--font-face);
  font-size: var(--font-size);
}

.editor-container .cm-tooltip code {
  font-family: var(--font-mono-face);
  font-size: var(--font-mono-size);
  /* If used with Bootstrap, we need to override Bootstrap's wrapping behavior
  for <code>. */
  white-space: pre-wrap;
}

.editor-container .cm-diagnostic {
  font-family: var(--font-mono-face);
  font-size: var(--font-mono-size);
}

.editor-container .cm-signature-signature {
  font-family: var(--font-mono-face);
}

/* The tooltip shown when hovering, with the formatted docstring. */
.editor-container .docstring {
  padding: 3px 6px;
  max-width: 650px;
  max-height: 300px;
  overflow-y: auto;
}

.editor-container .docstring pre {
  white-space: pre-wrap;
}

.editor-container .docstring h2 {
  font-size: 1.2em;
  font-weight: 600;
}

/* Code run button styles */
.shinylive-editor button.code-run-button {
  border: none;
  font-size: 0.8rem;
  padding: 0.2rem 0.5rem;
  background-color: transparent;
  white-space: nowrap;
}

.shinylive-editor .code-run-button:hover {
  color: var(--button-hover-color);
  fill: var(--button-hover-color);
}

/* When in the header of the app next to file tabs */
.editor-header .code-run-button {
  align-self: center;
  color: var(--button-gray-color);
  fill: var(--button-gray-color);
}

.shinylive-editor .floating-buttons .code-run-button {
  position: absolute;
  top: 0;
  right: 0;
  border: 0;
  margin-top: 5px;
  margin-right: 5px;
  opacity: 0;
}

.shinylive-editor:hover .floating-buttons .code-run-button {
  color: var(--button-gray-color);
  fill: var(--button-gray-color);
  opacity: 1;
}

.shinylive-editor .floating-buttons .code-run-button:hover {
  color: var(--button-hover-color);
  fill: var(--button-hover-color);
}
